<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断奇偶</title>
</head>
<body>
    <script>
        var x=prompt('请输入一个自然数');
        if(x>=0)
        {
            if(x==0||x%2==0)
            alert('是偶数');
            else
            alert('是奇数');
        }
        else
        alert('不是自然数');
    </script>
</body>
</html>